package com.ktjy.controller;

import com.ktjy.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@PropertySource(value = "classpath:user.properties",encoding = "utf-8")
public class HelloWorldController {
    @Value("${name2}")
    private String name;
    @Value("${age2}")
    private Integer age;

    @Autowired
    private User user;

    @RequestMapping("/test1")
    public String test1(){
        return "hello spring boot";
    }
    @RequestMapping("/test2")
    public String test2(){
        return "hello spring boot name="+name+",age="+age;
    }

    @RequestMapping("/test3")
    public String test3(){
        return "hello spring boot name="+user.getUsername()+",age="+user.getAge();
    }
}
